<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日志查询（全局）</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-disabled, .layui-disabled:hover {
            color: #000000 !important;
            cursor: not-allowed !important;
        }

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="layui-tab table_div">
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item" style="margin-left: 10px">
                                    <div class="layui-input-inline">
                                        <input type="text" readonly class="layui-input" id="createTime"
                                               placeholder="创建时间">
                                    </div>
                                    <div class="layui-input-inline layui-form">
                                        <select id="logType">
                                            <option value="">日志类型</option>
                                            <option value="1">日常日志</option>
                                            <option value="2">案件日志</option>
                                        </select>
                                    </div>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" id="createName" placeholder="填写人">
                                    </div>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" id="taxPerson" placeholder="确认人">
                                    </div>
                                    <div class="layui-input-inline ">
                                        <button class="layui-btn" onclick="searchLog()" id="search">查询</button>
                                        <button class="layui-btn" onclick="exportData()" id="exportData">导出</button>
                                    </div>
                                </div>
                                <table class="layui-table" id="logShowTable" lay-filter="logShowTable"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="logToolbar"></script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="cancel">返回</button>
    </div>
</script>
<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-xs" lay-event="addinspectionhear">填写日志</a>
</script>

<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var logShowTable;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var mold = "";
    var startTime = null;
    var endTime = null;

    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        form.on('select(mold)', function () {
            var myselect = document.getElementById("mold");
            var index = myselect.selectedIndex; // selectedIndex代表的是你所选中项的index
            mold = myselect.options[index].value;
        });
        //创建日期
        laydate.render({
            elem: '#createTime'
            , type: 'datetime'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }
            }
        });
        const mapArr = {
            'dictId': "1712894076144693250",
        };
        CoreUtil.sendPost("/sysDictDetail/list", mapArr, function (res) {
            if (res.code === 0) {
                var value = res.data;
                var opt = "<option value = ''>请选择填报类型</option>";
                for (var i in value) {
                    opt += '<option value = "' + value[i].value + '">' + value[i].label + '</option>';
                }
                $("#mold").html(opt);
                form.render('select'); //需要渲染一下
            } else {
                layer.msg(res.msg);
                return false;
            }
        });
        //日期范围
        laydate.render({
            elem: '#contentdate'
            , type: 'datetime'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    contentdate = value.split("~")[0];
                } else {
                    //清空时间的时候要清空以前选择的日期
                    contentdate = null;
                }
            }
        });
        // 工作日志
        logShowTable = table.render({
            elem: '#logShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/log/querylist1' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '日志编号',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 168,
                    field: 'createId',
                    title: '填写人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 268,
                    field: 'taxPerson',
                    title: '确认人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'type',
                    title: '日志类型',
                    sort: true,
                    templet: function (item) {
                        if (item.type === "1") {
                            return "日常日志";
                        } else if (item.type === "2") {
                            return "案件日志";
                        } else {
                            return "未知：" + item.type;
                        }
                    }
                }, {
                    align: 'center',
                    width: 358,
                    field: 'taxorgcode',
                    title: '税务机关',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'createTime',
                    title: '日志日期',
                    sort: true, templet: function (d) {
                        if (!d.createTime) {
                            return '';
                        }
                        return layui.util.toDateString(d.createTime, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 218,
                    field: 'content1',
                    title: '完成工作',
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'sectionchiefContent',
                    title: '科长审批',
                    templet: function (item) {
                        if (item.sectionchiefContent == "") {
                            return "未审批内容";
                        } else {
                            return item.sectionchiefContent;
                        }
                    },
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'disciplineContent',
                    title: '纪检审批内容',
                    templet: function (item) {
                        if (item.disciplineContent == "") {
                            return "未审批";
                        } else {
                            return item.disciplineContent;
                        }
                    },
                    sort: true,
                },

                {
                    align: 'center',
                    width: 260,
                    field: 'ajmc',
                    title: '企业名称',
                    sort: true,
                },
                {
                    align: 'center',
                    width: 180,
                    field: 'ajbh',
                    title: '案件编号',
                    sort: true,
                }
            ]],
            toolbar: '#logToolbar'
        });
    });

    function searchLog() {
        logShowTable.reload({
            where: {
                type: $("#logType").val(),
                createName: $("#createName").val(),
                startTime: startTime,
                endTime: endTime,
                taxPerson: $("#taxPerson").val(),
            },
            page: {
                curr: 1
            }
        });
    }

    function exportData() {
        var map = {
            type: $("#logType").val(),
            createName: $("#createName").val(),
            startTime: startTime,
            endTime: endTime,
        }
        CoreUtil.sendPost("/workflow/log/exportQuerylist1", map, function (res) {
            if (res.code === 0) {
                var file = res.data[2];
                window.open(file, '_blank');
            } else {
                layer.msg(res.msg);
                return false;
            }
        });
    }

</script>

</body>
</html>